Add cookieless analytics, kept out of the repository - #38
Merged
Conversation
Umami rather than Google Analytics: it sets no cookies, so the site needs no consent banner, which GA4 would have required. The website ID is read from .env.production.local, which is gitignored, and the script is injected at runtime only when that ID is present. A fork therefore gets nothing at all — with no ID the guard makes the whole branch unreachable and the bundler drops it, so even the tracker's URL is absent from the build. Vite reads .env.production.local for `vite build` and never for `vite dev`, so working locally cannot put localhost traffic in the stats. The env block in .gitignore listed five specific files with no glob, which left .env.production and the like committable. Replaced with a glob and an exception for the template. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013yxFHbQB5DPVd9cRZNW3A9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Traffic and referrer stats, using Umami rather than Google Analytics: it
sets no cookies, so no consent banner is needed. Matches the setup on
jamiepates.com.
Nothing here reaches a fork
The website ID is read from
frontend/.env.production.local, which isgitignored, and the script is injected at runtime only when that ID is
present. With no ID the guard makes the branch unreachable and the bundler
drops it, so a fork has no script tag, no request, and not even the tracker's
URL in the build — verified by grepping
dist/..env.production.localrather than.env.localbecause Vite reads it forvite buildand never forvite dev, so working locally cannot put localhosttraffic in the stats.
.env.exampleis committed so the setup is discoverable, and so anyoneforking has an obvious place for their own ID.
Also
The
.gitignoreenv block listed five specific files with no glob, leaving.env.productionand similar committable. Replaced with a glob and anexception for the template.
Testing
npm run buildclean, anddist/contains no trace of the tracker without anID. The equivalent change on jamiepates.com was verified end to end in a
browser: tag injected, page view accepted by Umami, no duplicates.
Before this does anything
Create
frontend/.env.production.localwith a website ID from the Umamidashboard — a separate one from the other sites, or the stats merge — then
rebuild and upload. Until then the site behaves exactly as it does today.
🤖 Generated with Claude Code
https://claude.ai/code/session_013yxFHbQB5DPVd9cRZNW3A9